package com.yami.shop.common.config;


import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.util.Properties;

@EnableCaching
@Configuration
public class WechatPayProperties {

    private static Properties wechatPayProperties;

    public WechatPayProperties(){
        try {
            if (wechatPayProperties == null) {
                wechatPayProperties = PropertiesLoaderUtils.loadAllProperties("config/wechatPay.properties");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    private String appId;
    private String secret;
    private String grantType;
    private String mchId;
    private String wxPayUnifiedOrder;
    private String wxPayUnifiedOrderV2;
    private String wxNotifyUrl;
    private String wxPayNative;
    private String APIv3;
    private String wxRefunds;
    private String wxRefundNotifyUrl;


    public String getWxPayUnifiedOrderV2() {
        return wechatPayProperties.getProperty("wechat.wxPayUnifiedOrderV2");
    }

    public String getWxRefundNotifyUrl() {
        return wechatPayProperties.getProperty("wechat.wxRefundNotifyUrl");
    }

    public String getWxRefunds() {
        return wechatPayProperties.getProperty("wechat.wxRefunds");
    }
    public String getAppId() {
        return wechatPayProperties.getProperty("wechat.appId");
    }

    public String getSecret() {
        return wechatPayProperties.getProperty("wechat.secret");
    }

    public String getGrantType() {
        return wechatPayProperties.getProperty("alipay.aliPublicKey");
    }


    public String getMchId() {
        return wechatPayProperties.getProperty("wechat.mchId");
    }

    public String getWxPayUnifiedOrder() {
        return wechatPayProperties.getProperty("wechat.wxPayUnifiedOrder");
    }

    public String getWxNotifyUrl() {
        return wechatPayProperties.getProperty("wechat.wxNotifyUrl");
    }

    public Properties getWechatPayProperties() throws IOException {
        return  wechatPayProperties;
    }

    public String getWxPayNative() {
        return wechatPayProperties.getProperty("wechat.wxPayNative");
    }

    public String getAPIv3() {
        return wechatPayProperties.getProperty("wechat.APIv3");
    }
}
